package com.xuecheng.order.dao;

import com.xuecheng.framework.domain.task.XcTask;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;

/**
 * @author Kidy
 * @date 2020/7/17 22:36
 */
public interface XcTaskRepository extends JpaRepository<XcTask, String> {

    //某时间之前的前n条数据
    public Page<XcTask> findByUpdateTimeBefore(Pageable pageable, Date updateTime);

    @Modifying
    @Query("update XcTask set updateTime = ?2 where id = ?1")
    public int updateTaskTime(String id, Date updateTime);

    @Modifying
    @Query("update XcTask set version = ?2+1 where id = ?1 and version = ?2")
    public int updateVersion(String id, int version);
}
